package com.firexxx.vp.infrastructure.aop;

import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2020/02/20 20:01
 */
@Component
public class TraceInterceptor implements HandlerInterceptor {

    private final static String TRACE_UUID = "trace_uuid";

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String sid = request.getHeader("sid");
        MDC.put(TRACE_UUID, sid);

        return true;
    }
}